package fr.jade.service.nodes.allocator;

import java.util.Collection;

import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.NoSuchInterfaceException;


/**
 * Basic interface for node allocation.
 * @author nono
 * @author Sylvain Sicard
 * @contact sylvain.sicard@gmail.com
 * 
 */
public interface Allocator {
  
	/**
	 * Try to allocate a free node.
	 * @param pNode name of a physical node
	 * @return the nodes allocated.
	 * @throws AllocatorException 
	 * @throws NoSuchInterfaceException 
	 */
	Component alloc(String pNode) throws AllocatorException;
	
	/**
	 * Free the node
	 * @param gf the node to free
	 */
	void free(Component gf);
	
	/**
	 * return the current allocated nodes.
	 * @return the nodes allocated. null if all nodes are free
	 */
	Collection<Component> getAllocated();
	
	/**
	 * return the current free nodes.
	 * @return the nodes free. null if all nodes are allocated
	 */
	Collection<Component> getFree();
	
}
